<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-11-06 09:27
 *
 * 项目：rm  -  $  - FormController.php
 *
 * 作者：liwei 
 */

namespace modules\levfm\controllers;

use Lev;
use lev\base\Assetsv;
use lev\base\Controllerv;
use lev\base\Viewv;
use modules\levfm\helpers\UrlfmHelper;
use modules\levfm\table\LevfmForms;

!defined('INLEV') && exit('Access Denied LEV');


class FormController extends Controllerv
{

    public static function Form() {
        $opid = Lev::stripTags(Lev::GPv('opid'));
        if (stripos($opid, 'id') === 0) {
            unset($_GET['opid']);
            $formid = $_GET['form'] = substr($opid, 2);
            $opid   = 0;
        }else {
            $formid = null;
            //$opid   = floatval($opid);
        }


        return FormDataController::Form($opid, $formid);

    }

    public static function actionIndex() {

        $param = static::Form();//print_r($param);

        if (LevfmForms::isVoteForm($param['formInfo']['settings'])) {
            VoteController::actionIndex($param);
        }else {
            FormDataController::actionIndex($param);
        }
    }

    public static function actionList() {
        $formInfo = ListController::formInfo();

        if (LevfmForms::isVoteForm($formInfo['settings'])) {
            //VoteController::actionIndex();
            parent::redirect(UrlfmHelper::forms(0, $formInfo['id']));
        }else {
            ListController::actionIndex();
        }
    }

    public static function actionView() {
        ViewController::actionIndex();
    }
}